package n2533;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static int a[]=new int[1000];
	static int N;
	static int solve()
	{
		int b[]=new int[N+1];
		b[0]=0;
		b[1]=a[0];
		int len=1,l,r,mid;
		for(int i=0;i<N;i++)
		{
			l=1;r=len;
			while(l<=r)
			{
				mid=(l+r)>>1;
				if(b[mid]<a[i])l=mid+1;
				else if(b[mid]>a[i])r=mid-1;
				else{
					l=mid;
					break;
				}
			}
			b[l]=a[i];
			if(l>len)len++;
		}
		return len;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		N=Integer.parseInt(bf.readLine());
		StringTokenizer st=new StringTokenizer(bf.readLine());
		for(int i=0;i<N;i++)
		{
			a[i]=Integer.parseInt(st.nextToken());
		}
		System.out.println(solve());
	}

}
